﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UwinEducation.Domain.Entities;
using UwinEducation.Shared.Models;

namespace UwinEducation.Domain.IRepositories
{
    /// <summary>
    /// 学生课表仓储接口
    /// </summary>
    public interface IStudentScheduleRepository : IRepository<StudentSchedule, Guid>
    {
        /// <summary>
        /// 获取学生课表分页列表
        /// </summary>
        Task<PagedResult<StudentSchedule>> GetPagedListAsync(StudentSchedulePageRequest pageRequest);

        /// <summary>
        /// 获取学生课表详情
        /// </summary>
        Task<StudentSchedule> GetDetailsByIdAsync(Guid id);

        /// <summary>
        /// 获取学生的所有课表
        /// </summary>
        Task<List<StudentSchedule>> GetByStudentIdAsync(Guid studentId);

        /// <summary>
        /// 获取指定日期范围内的学生课表
        /// </summary>
        Task<List<StudentSchedule>> GetByDateRangeAsync(Guid studentId, DateTime? startDate, DateTime? endDate);
        Task<List<StudentSchedule>> GetByDateRangeAsync(Guid studentId,Guid? TeacherScheduleId, DateTime? startDate, DateTime? endDate);
        /// <summary>
        /// 根据教师课表ID获取学生课表
        /// </summary>
        /// <param name="teacherScheduleId">教师课表ID</param>
        /// <returns>学生课表信息</returns>
        Task<StudentSchedule> GetByTeacherScheduleIdAsync(Guid teacherScheduleId,Guid studentId);


        /// <summary>
        /// 批量获取学生课表
        /// </summary>
        /// <param name="teacherScheduleIds">教师课表ID列表</param>
        /// <param name="studentId">学生ID</param>
        /// <returns>学生课表列表</returns>
        Task<List<StudentSchedule>> GetByTeacherScheduleIdsAsync(List<Guid> teacherScheduleIds,Guid studentId);

        /// <summary>
        /// 获取教师课表组已使用的容量
        /// </summary>
        /// <param name="teacherScheduleGroupId">教师课表组ID</param>
        /// <returns>已使用的容量</returns>
        Task<int> GetUsedCapacityByTeacherScheduleGroupIdAsync(Guid teacherScheduleGroupId);

        /// <summary>
        /// 获取每个课表的报名人数
        /// </summary>
        Task<List<(Guid TeacherScheduleId, int EnrolledCount)>> GetEnrolledCountByTeacherScheduleIdsAsync(List<Guid> teacherScheduleIds);
        Task<List<(Guid TeacherScheduleDetailsId, int EnrolledCount)>> GetEnrolledCountByTeacherScheduleDetailsIdsAsync(List<Guid> teacherScheduleDetailsIds);
        /// <summary>
        /// 获取学生所有现有课表
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        Task<List<StudentSchedule>> GetByStudentIdAsync(Guid studentId, DateTime startTime, DateTime endTime);
        /// <summary>
        /// 获取学生课表统计分页列表
        /// </summary>
        /// <param name="pageRequest"></param>
        /// <returns></returns>
        Task<PagedResult<(StudentSchedule studentSchedule,int courseCount)>> GetStatisticsPagedListAsync(StudentScheduleStatisticsPageRequest pageRequest);
        /// <summary>
        /// 获取教师课表集合
        /// </summary>
        /// <param name="teacherId"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        Task<List<StudentSchedule>> GetByTeacherIdAndDateRangeAsync(Guid teacherId, DateTime startDate, DateTime endDate);
        /// <summary>
        /// 根据学生ID和教师课表ID删除学生课表
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="teacherScheduleId"></param>
        /// <returns></returns>
        Task DeleteByStudentIdAndTeacherScheduleIdAsync(Guid studentId, Guid teacherScheduleId);

        /// <summary>   
        /// 根据学生ID和教师课表ID获取学生课表
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="teacherScheduleId"></param>
        /// <returns></returns>
        Task<List<StudentSchedule>> GetByStudentIdAndTeacherScheduleIdAsync(Guid studentId, Guid teacherScheduleId);

        Task<List<Student>> GetDistinctStudentsByTeacherScheduleIdAsync(Guid teacherScheduleId);

    }
}


